#ifndef __UART_H
#define __UART_H	
#include "stm32f10x.h" 
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include "Delay.h"

#define RX_BUFFER_SIZE 128

extern volatile uint8_t rx_buffer1[RX_BUFFER_SIZE];
extern volatile uint8_t rx_buffer2[RX_BUFFER_SIZE];
extern volatile uint8_t rx_buffer[RX_BUFFER_SIZE];
extern volatile uint8_t rx_buffer_clear[RX_BUFFER_SIZE];
extern volatile uint16_t rx_index;

extern volatile uint8_t received_flag_1;
extern volatile uint8_t received_flag_2;
extern volatile uint8_t received_flag_3;



extern volatile float global_angle;
extern volatile uint8_t new_data_received;
extern volatile float angular_velocity_y;
extern volatile float angular_velocity_z;
extern uint8_t received_data_packet[11];



void USART1_Init(uint32_t bit);
void USART2_Init(uint32_t bit);
void USART3_Init(uint32_t bit);

void USART1_IRQHandler(void);
void USART2_IRQHandler(void);
void USART3_IRQHandler(void);

void USART1_SendByte(uint8_t data);
void USART1_SendString(char *str);
void USART1_SendBuffer(uint8_t *buf, uint16_t len);

void USART2_SendByte(uint8_t data);
void USART2_SendString(char *str);
void USART2_SendBuffer(uint8_t *buf, uint16_t len);



void USART3_SendByte(uint8_t data);
void Usart3_SendString(char *String);
void Usart3_SendArray(uint8_t *array, uint16_t length);
void Usart3_Printf(char *format, ...);
void ParseAndPrintData(uint8_t *data, uint16_t length);
uint8_t CalculateChecksum(uint8_t *data, uint16_t length, uint8_t type);





#endif
